import React from "react";
import { Cascader } from "antd";
// import provinceList from "@/assets/js/provinceList.json";
import { city } from "@/assets/js/provinceList";
import type { CascaderProps, GetProp } from "antd";
type DefaultOptionType = GetProp<CascaderProps, "options">[number];
interface Option {
  code: string;
  name: string;
  children?: Option[];
}


// console.log(provinceList, "===");

// const opt =provinceList.map;

const onChange: CascaderProps<Option>["onChange"] = (value) => {
  console.log(value);
};
const filter = (inputValue: string, path: DefaultOptionType[]) =>
  path.some((option) => (option.name as string).indexOf(inputValue) > -1);
const App: React.FC = () => (
  <Cascader
    fieldNames={{ label: "name", value: "code", children: "children" }}
    options={city}
    showSearch={{ filter }}
    onSearch={(value) => console.log(value)}
    onChange={onChange}
    placeholder="Please select"
  />
);

export default App;
